package com.cuijq.ms.strategy.v2.impl;

import com.cuijq.ms.strategy.v2.DiscountStrategy;
import com.cuijq.ms.strategy.v2.OrderType;
import java.util.HashMap;
import java.util.Map;

/**
 * @author by CuiJQ
 * @Classname DiscountStrategyFactory
 * @Description DiscountStrategyFactory Description
 * @Date 2021/5/28 21:01
 */
public class DiscountStrategyFactory {

  private static final Map<OrderType, DiscountStrategy> strategies = new HashMap<>();

  static {
    strategies.put(OrderType.NORMAL, new NormalDiscountStrategy());
    strategies.put(OrderType.GROUPON, new GrouponDiscountStrategy());
    strategies.put(OrderType.PROMOTION, new PromotionDiscountStrategy());
  }

  public static DiscountStrategy getDiscountStrategy(OrderType type) {
    return strategies.get(type);
  }
}
